{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Calculating MAGIC...\n",
      "Calculating graph and diffusion operator...\n",
      "Calculating PCA...\n",
      "Calculated PCA in 7.59 seconds.\n",
      "Calculating KNN search...\n",
      "Calculated KNN search in 1.40 seconds.\n",
      "Calculating affinities...\n",
      "Calculated affinities in 0.12 seconds.\n",
      "Calculated graph and diffusion operator in 9.47 seconds.\n",
      "Calculating imputation...\n",
      "Automatically selected t = 7\n",
      "Calculated imputation in 0.17 seconds.\n",
      "Calculated MAGIC in 12.30 seconds.\n",
      "--- 21.142620086669922 seconds ---\n"
     ]
    }
   ],
   "source": [
    "import magic\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import time\n",
    "start_time = time.time()\n",
    "X = pd.read_csv(\"~/rerun/zeisel_raw.csv\",header = 0,index_col=0)\n",
    "X = X.transpose()\n",
    "magic_operator = magic.MAGIC()\n",
    "X_magic = magic_operator.fit_transform(X)\n",
    "print(\"--- %s seconds ---\" % (time.time() - start_time))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.DataFrame.to_csv(X_magic.transpose(), \"~/rerun/zeisel_magic.csv\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
